*for REStat paper, "Breastfeeding and Children's Early Cognitive Outcomes."
libname dd 'X:\Donnanew';

data x;
  set dd.mdid2;

proc sort;  by pcg97id;  run;

data y;
set dd.pind08;
keep intnum00-intnum99 hw00-hw99 pcg97id;

intnum83 = er30399;
intnum84 = er30429;
intnum85 = er30463;
intnum86 = er30498;
intnum87 = er30535;
intnum88 = er30570;
intnum89 = er30606;
intnum90 = er30642;
intnum91 = er30689;
intnum92 = er30733;
intnum93 = er30806;
intnum94 = er33101;
intnum95 = er33201;
intnum96 = er33301;
intnum97 = er33401;
intnum99 = er33501;
intnum01 = er33601;
intnum03 = er33701;
intnum05 = er33801;

*will code head/wife has 1 head 2 wife;
if er30401 = 10 then hw83 = 1;
if (er30401 = 20 or er30401 = 22) then hw83 = 2;

if er30431 = 10 then hw84 = 1;
if (er30431 = 20 or er30431 = 22) then hw84 = 2;

if er30465 = 10 then hw85 = 1;
if (er30465 = 20 or er30465 = 22) then hw85 = 2;

if er30500 = 10 then hw86 = 1;
if (er30500 = 20 or er30500 = 22) then hw86 = 2;

if er30537 = 10 then hw87 = 1;
if (er30537 = 20 or er30537 = 22) then hw87 = 2;

if er30572 = 10 then hw88 = 1;
if (er30572 = 20 or er30572 = 22) then hw88 = 2;

if er30608 = 10 then hw89 = 1;
if (er30608 = 20 or er30608 = 22) then hw89 = 2;

if er30644 = 10 then hw90 = 1;
if (er30644 = 20 or er30644 = 22) then hw90 = 2;

if er30691 = 10 then hw91 = 1;
if (er30691 = 20 or er30691 = 22) then hw91 = 2;

if er30735 = 10 then hw92 = 1;
if (er30735 = 20 or er30735 = 22) then hw92 = 2;

if er30808 = 10 then hw93 = 1;
if (er30808 = 20 or er30808 = 22) then hw93 = 2;

if er33103 = 10 then hw94 = 1;
if (er33103 = 20 or er33103 = 22) then hw94 = 2;

if er33203 = 10 then hw95 = 1;
if (er33203 = 20 or er33203 = 22) then hw95 = 2;

if er33303 = 10 then hw96 = 1;
if (er33303 = 20 or er33303 = 22) then hw96 = 2;

if er33403 = 10 then hw97 = 1;
if (er33403 = 20 or er33403 = 22) then hw97 = 2;

if er33503 = 10 then hw99 = 1;
if (er33503 = 20 or er33503 = 22) then hw99 = 2;

if er33603 = 10 then hw01 = 1;
if (er33603 = 20 or er33603 = 22) then hw01 = 2;

if er33703 = 10 then hw03 = 1;
if (er33703 = 20 or er33703 = 22) then hw03 = 2;

if er33803 = 10 then hw05 = 1;
if (er33803 = 20 or er33803 = 22) then hw05 = 2;


pcg97id = er30001*1000 + er30002;

proc sort;  by pcg97id;

data dd.pindpcg;
merge x y;  by pcg97id;  


if childid ne .;


proc means;
run;
